package tech.waterism.utils;

import tech.waterism.dto.*;

import java.util.Date;
import java.util.List;

/**
 * todo remove
 * 临时调度规则
 */
public class TempDispatchRule {
    public static void dispatch(FPIndexDto fpIndex, Date fymdh) {
        String stcd = fpIndex.getStcd();
        List<ForecastDataDto> data = fpIndex.getData();
        switch (stcd) {
            case "2020551A":
                for (ForecastDataDto datum : data) {
                    if (!datum.getDt().after(fymdh)) {
                        continue;
                    }
                    Double q = datum.getQSim();
                    datum.setQIn(q);
                    if (q <= 1000) {
                        q = 0.4 * q;
                    } else if (q <= 1820) {
                        q = q - 600;
                    } else if (q <= 2020) {
                        q = q - 700;
                    } else if (q <= 2070) {
                        q = q - 800;
                    } else {
                        q = q - 1000;
                    }
                    datum.setQOut(q);
                }
                break;
            case "2010060A":
                for (ForecastDataDto datum : data) {
                    if (!datum.getDt().after(fymdh)) {
                        continue;
                    }
                    Double q = datum.getQSim();
                    datum.setQIn(q);
                    if (q <= 360) {
                        q = q;
                    } else if (q <= 675) {
                        q = 360d;
                    } else if (q <= 1800) {
                        q = q;
                    } else if (q <= 2115) {
                        q = 1800d;
                    } else {
                        q = q - 315;
                    }
                    datum.setQOut(q);
                }
                break;
            case "2010190A":
                for (ForecastDataDto datum : data) {
                    if (!datum.getDt().after(fymdh)) {
                        continue;
                    }
                    Double q = datum.getQSim();
                    datum.setQIn(q);
                    if (q <= 360) {
                        q = 0d;
                    } else if (q <= 1360) {
                        q = q - 60;
                    } else if (q <= 1660) {
                        q = 1300d;
                    } else {
                        q = q - 360;
                    }
                    datum.setQOut(q);
                }
                break;

            default:
                for (ForecastDataDto datum : data) {
                    if (!datum.getDt().after(fymdh)) {
                        continue;
                    }
                    datum.setQOut(datum.getQSim());
                }
        }
    }
}
